package cn.com.huzo.test.workflow;

import org.activiti.engine.HistoryService;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

/**
 * 工作流测试抽象类
 * <p>
 * @author 吴旭
 * 2014-10-30
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
    locations = {"classpath:/applicationContext-activiti.xml",
                 "classpath*:/applicationContext.xml",
                 "/WEB-INF/applicationContext*.xml"}
)
@Transactional
public abstract class BaseWorkFlowTestCase extends AbstractTransactionalJUnit4SpringContextTests {

    protected transient final Log log = LogFactory.getLog(getClass());

    @SuppressWarnings("unused")
    @Autowired
    private ProcessEngine processEngine;
    @Autowired
    protected RepositoryService repositoryService;
    @Autowired
    protected RuntimeService runtimeService;
    @Autowired
    protected TaskService taskService;
    @Autowired
    protected HistoryService historyService;
    @Autowired
    protected ManagementService managementService;

    protected String deploymentId;

    public BaseWorkFlowTestCase() {
        super();
    }

    @Before
    public void initialize() throws Exception {
        beforeTest();
    }

    @After
    public void clean() throws Exception {
        afterTest();
    }

    protected abstract void beforeTest() throws Exception;

    protected abstract void afterTest() throws Exception;
}
